package com.itheima.jobs;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class CleanOrderSettingJob {

    @Reference
    private OrderSettingService orderSettingService;

    // 定时清理过去的数据
    public void clearOrderSetting(){
        try {
            Calendar c = Calendar.getInstance();
            c.add(Calendar.MONTH,-10);
            Date date = c.getTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            String format = sdf.format(date);
            format = format + "-31";
            orderSettingService.clean(format);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
